﻿<html>
<header>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="css/jquery.mobile-1.4.3.min.css" /> 
    <script src="js/jquery-1.11.1.min.js"></script> 
    <script src="js/jquery.mobile-1.4.3.min.js"></script> 
	<script src='js/timeout.js'></script>
	<script type="text/javascript" charset="utf-8" src="cordova.js"></script>      
    <script type="text/javascript" src="PushNotification.js"></script>        
	<script type="text/javascript" src="js/gcm.js"></script>
</header>
<script>
$(document).ready(function() {
	var bool=false;
	dropdown(bool)
});
function dropdown(bool)
{
	if (bool==false)
	{
		$.ajax({
			type: 'post',
			url:'https://163.15.192.205/vany/index.php/gcm/select_url',
			datatype:'JSON',
			success: function(response) {
				var data=eval(response);
				console.log(data);
				for (var i=0;i<data.length;i++)
				{
					$('#url').append($('<option></option>').val(data[i]['url']).text(data[i]['name']));
				}
				bool=true;
				$("#check").click(btnclick);
			}
		});
	}
}

function btnclick(bool)
{
	if($('#url').val()==null)
	{
		alert("請選擇URL");
	}
	else 
	{
		$.ajax({
			type: 'post',
			url: 'https://163.15.192.205/vany/index.php/gcm/test_conn',
			datatype: "json",
			cache: false,
			crossDomain: true,
			data:{
				url:$('#url').val()
			},				
			success: function(con) {
				alert(con);
				bool=false;
				
			},		
		});
	}
}
 
</script>
<body>
        <div data-role="page">
            <div data-role="header" data-dividertheme="a" data-position="fixed">
				<a data-icon="grid" href='menu.html' data-ajax = 'false'>功能表</a>
				<H1>檢測連線</H1>
			</div>
            <div data-role="content">
				<h3>請選擇URL:</h3>
				<select id="url" name="url"></select>
				<input type="button" ID="check" value="送出"></BUTTON>
            </div>
            <div data-role="footer" data-position="fixed"><h2>inwinSTACK</h2></div>
        </div>
		<!--==============訊息視窗================-->
		<div data-role="page" id="sure">
			<div style="margin-top:50%;">
				<div data-role="header">
					<h3 class="sure-1"></h3>
				</div>
				<div role="main" class="ui-content">
					<p class="sure-2"></p>
					<a href="#" data-role="button" data-rel="back" data-theme="b">確定</a> 
				</div>
			</div>	
		</div>
		<!--==============訊息視窗================-->
    </div>
</body>
</html>